﻿using HttpApiGateway;
using RpcClient;
using RpcHelper.Validate;
using RpcModel;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using Wedonek.RpcStore.Service.Model;
namespace Wedonek.RpcStore.Gateway.Controller
{
    /// <summary>
    /// 服务运行状态
    /// </summary>
    internal class ServerRunStateController : ApiController
    {
        private readonly IServerRunStateService _Server;
        public ServerRunStateController(IServerRunStateService server)
        {
            this._Server = server;
        }
        /// <summary>
        /// 获取服务节点运行状态
        /// </summary>
        /// <param name="serverId"></param>
        /// <returns></returns>
        public ServerRunState Get([NumValidate("rpc.server.id.error", 1)] long serverId)
        {
            return this._Server.Get(serverId);
        }
        /// <summary>
        /// 服务运行状态查询
        /// </summary>
        /// <param name="paging"></param>
        /// <returns></returns>
        public PagingResult<RunState> Query(IBasicPage paging)
        {
            RunState[] list = this._Server.Query(paging, out long count);
            return new PagingResult<RunState>(list, count);
        }
    }
}
